<?php
    session_start();
	
	$historico=$_REQUEST['Historico'];
	$activo=$_REQUEST['Activo'];
	$idACambiar=$_REQUEST['identificadorAnuncio'];
	
	
	include("TableDataGateway/TDGHistorico.php");
	$TDG = new TDGHistorico();
	
	
	if(!empty($idACambiar)){
		$TDG->cambiarEstado($idACambiar);
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Vitamina U</title>
        <meta name="keywords" content="itinerary, list" />
        <meta name="description" content="This page provides a list of all itineraries" />
        <link href="css/default.css" rel="stylesheet" type="text/css" />
    </head>
    
    
    <body>
		<div id="wrapper">
        <?php include 'include/header2.php'; ?>
            <!-- end div#header -->
            <div id="page2">
                <div id="content">
                    <div id="welcome">
					<center><h1>Manipular el Hist&oacute;rico</h1>
					<form id="form_datos" action="administrarhistorico.php" method="POST">
						<input class="form_submitb" type="submit" name="Historico" id="Historico"  value="Ver Historico"/>
						<input class="form_submitb" type="submit" name="Activo" id="Activo"  value="Ver Activos"/><br/><br/>
					</form>
					
					<?php
						if($historico!=NULL){
							$result = $TDG->recuperarDatos(0);
							IF($result){
								echo "<center><table border = '0'> \n";
								echo "<tr> \n";
								echo "<th><font color=#AA2808><center><b>Nombre</b></center></font></th> \n";
								echo "<th><font color=#AA2808><center><b>ID</b></center></font></th> \n";
								echo "</tr> \n";
								while ($row = mysql_fetch_row($result)){
									echo "<tr> \n";
									echo "<FORM METHOD='POST' ACTION='administrarhistorico.php'>";
									echo "<td>$row[0]</td> \n";
									echo "<td>$row[1]</td> \n";
									echo "<input type='hidden' name='identificadorAnuncio' id='identificadorAnuncio' value='$row[1]'>";
									echo "<td><center><input class='form_submitb' type='submit' value='Cambiar' ></center></td> \n";
									echo "</FORM>";
									echo "</tr> \n";
								}
								echo "</table></center> \n";
							}else{
								
							}
						}else{
							if($activo!=NULL){
							$result = $TDG->recuperarDatos(1);
								IF($result){
									echo "<center><table border = '0'> \n";
									echo "<tr> \n";
									echo "<th><font color=#AA2808><center><b>Nombre</b></center><font></th> \n";
									echo "<th><font color=#AA2808><center><b>ID</b></center><font></th> \n";
									//echo "<th><font color=#AA2808><b>Cambiar estado</b><font></th> \n";
									echo "</tr> \n";
									while ($row = mysql_fetch_row($result)){
										echo "<tr> \n";
										echo "<FORM METHOD='POST' ACTION='administrarhistorico.php'>";
										echo "<td>$row[0]</td> \n";
										echo "<td>$row[1]</td> \n";
										echo "<input type='hidden' name='identificadorAnuncio' id='identificadorAnuncio' value='$row[1]'>";
										echo "<td><center><input class='form_submitb' type='submit' value='Cambiar' ></center></td> \n";
										echo "</FORM>";
										echo "</tr> \n";
									}
									echo "</table></center> \n";
								}else{
									ECHO "No hay resultados";
								}
							}
						}
					?>
					</center>
                    </div>
                    
                    <!-- end div#welcome -->			
                    
                </div>
                <!-- end div#content -->
				
				<div id="sidebar">
					<br/><br/>
                    <center><H1>Opciones<H1></center>
                </div>
				
                <div style="clear: both; height: 1px"></div>
            </div>
            <?php include 'include/footer2.php'; ?>

        </div>
        <!-- end div#wrapper -->
    </body>
</html>